package pl.tssoft.math.core;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author tserafin
 */
public class Workspace {

    private Map<String, Value> variables = new HashMap<String, Value>();

    public boolean variableExists(String name) {
        return variables.containsKey(name);
    }

    public void setVariable(Value variable) {
        String name = variable.getName();
        if (name == null || name.equals("")) {
            return;
        }
        variables.put(name, variable);
    }

    public Value getVariable(String name) {
        return variables.get(name);
    }
    
    public void removeVariable(String name) {
        variables.remove(name);
    }

    public void clearVariables() {
        variables.clear();
    }
}
